<script setup lang="ts">
import { RouteLocationNormalizedLoaded, Router } from "vue-router";

const router: Router = useRouter();
const route: RouteLocationNormalizedLoaded = useRoute();

let totalCnt: number = 0;

const waitAsyncRoute = (): boolean => {
  if (totalCnt > 10) {
    return false;
  }
  router.replace(route.path);
  const find = router.getRoutes().find((item) => item.path == route.path);
  if (!find) {
    setTimeout(() => {
      if (waitAsyncRoute()) {
        return true;
      }
    }, 500);
  }
  return false;
};

onMounted(() => {
  waitAsyncRoute();
});
</script>

<template>
  <div class="w-full h-full flex justify-center items-center flex-col">
    <p class="text-xl">
      I'm sorry，此页面不存在
    </p>
    <p class="text-base">
      <router-link to="/index" class=" text-primary">返回首页</router-link>
    </p>
  </div>
</template>

<style lang="scss" scoped></style>
